import os
from PIL import Image
import numpy as np
from segment_anything import SamAutomaticMaskGenerator, sam_model_registry
import matplotlib.pyplot as plt
import torch
import random
from tqdm import tqdm
import argparse
import warnings
warnings.filterwarnings('ignore', category=UserWarning)

from utils.common import check_and_create_directory, list_all_files, chunk_list
from utils.auto_sam import auto_sam
from utils.vit.vit import vit_encode

# 本段代码用来检查是否全部的数据都经过了处理
if __name__ == '__main__':
    tmp_path = '/home/zry/datasets/building/train/tmp'
    fpts = list_all_files(tmp_path, '.pt')
    for f in tqdm(fpts):
        pt = torch.load(f)
        n = int(pt.max().item())
        # print(n)
        for i in range(n):
            fi_base = f.replace('.pt', '')
            fi = os.path.join(tmp_path, '%s.%d.bbox' % (fi_base, i))
            if not os.path.exists(fi):
                print('Error', fi)

    print('Everythink is ok.')
    pass
